package com.aos.erp.manager.service.student.imp;

import com.aos.erp.common.bean.PageBean;
import com.aos.erp.manager.mapper.student.StudentMapper;
import com.aos.erp.manager.model.student.Student;
import com.aos.erp.manager.model.student.ro.SelectStudentRo;
import com.aos.erp.manager.model.student.vo.StudentAllVo;
import com.aos.erp.manager.service.student.StudentService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 学员信息表 服务实现类
 * </p>
 *
 * @author chb
 * @since 2018-10-31
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements StudentService {

    @Resource
    private StudentMapper  studentMapper;


    /**
     * 分页查询学员
     * @param ro
     * @return
     */
    @Override
    public PageBean<StudentAllVo> queryByPage(SelectStudentRo ro) {

        Page<StudentAllVo> page = new Page<StudentAllVo>(ro.getPageIndex(), ro.getPageSize());
        List<StudentAllVo> noticeInfoList = baseMapper.queryList(page, ro);
        page.setRecords(noticeInfoList);

        PageBean<StudentAllVo> bean = new PageBean<StudentAllVo>(page.getCurrent(), page.getSize(), page.getTotal());
        bean.setOptimizeCountSql(page.optimizeCountSql());
        bean.setAscs(page.ascs());
        bean.setDescs(page.descs());
        bean.setRecords(page.getRecords());
        bean.condition();
        return bean;
    }

    @Override
    public StudentAllVo queryObject(long id) {
        return studentMapper.queryObject(id);
    }
}
